package com.openbravo.pos.printer.printer;

import com.openbravo.pos.printer.ticket.BasicTicket;
import com.openbravo.pos.printer.ticket.PrintItem;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.util.List;

public class PrintableBasicTicket
  implements Printable
{
  private int imageable_width;
  private int imageable_height;
  private int imageable_x;
  private int imageable_y;
  private BasicTicket ticket;

  public PrintableBasicTicket(BasicTicket paramBasicTicket, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    this.ticket = paramBasicTicket;
    this.imageable_x = paramInt1;
    this.imageable_y = paramInt2;
    this.imageable_width = paramInt3;
    this.imageable_height = paramInt4;
  }

  public int print(Graphics paramGraphics, PageFormat paramPageFormat, int paramInt)
    throws PrinterException
  {
    Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
    int i = 0;
    int j = 0;
    int k = 0;
    int m = 0;
    localGraphics2D.translate(this.imageable_x, this.imageable_y);
    List localList = this.ticket.getCommands();
    while (i < localList.size())
    {
      int n = ((PrintItem)localList.get(i)).getHeight();
      if (k + n <= this.imageable_height)
      {
        k += n;
      }
      else
      {
        j++;
        k = n;
      }
      if (j < paramInt)
      {
        i++;
      }
      else if (j == paramInt)
      {
        m = 1;
        ((PrintItem)localList.get(i)).draw(localGraphics2D, 0, k - n, this.imageable_width);
        i++;
      }
      else if (j > paramInt)
      {
        i++;
      }
    }
    return m != 0 ? 0 : 1;
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.printer.printer.PrintableBasicTicket
 * JD-Core Version:    0.6.0
 */